﻿using PoliticalClassifier.Support;

namespace PoliticalClassifier.DataSource
{
    /// <summary>
    /// Provides an abstract base implementation of IDataSourceLoadError.
    /// </summary>
    internal abstract class DataSourceErrorBase : IDataSourceLoadError
    {
        #region Construction
        /// <summary>
        /// Constructs an error of the given type.
        /// </summary>
        /// <param name="errorType">The type of error.</param>
        protected DataSourceErrorBase(DataSourceLoadErrorType errorType)
        {
            ErrorType = errorType;
        }
        #endregion

        #region Public Properties
        /// <summary>
        /// Gets the type of error.
        /// </summary>
        public DataSourceLoadErrorType ErrorType { get; private set; }
        #endregion

        #region Public Methods
        /// <summary>
        /// Gets a human readable error message.
        /// </summary>
        /// <returns>A human readable error message.</returns>
        public abstract string GetErrorMessage();

        /// <summary>
        /// Overrides System.Object.ToString() to return a human readable error message.
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return GetErrorMessage();
        }
        #endregion
    }
}
